from PySide6.QtWidgets import QPlainTextEdit
from PySide6.QtCore import Qt

class PlainTextEdit(QPlainTextEdit):
    """纯文本编辑

    :param QPlainTextEdit: PySide6 QPlainTextEdit
    """

    def __init__(self):
        """初始化
        """
        super().__init__()

    def set_line_warp_mode(self,checked):
        """设置换行模式
        根据勾选状态设置换行模式和滚动条策略
        """
        if checked:
            self.setLineWrapMode(QPlainTextEdit.LineWrapMode.WidgetWidth)
            self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
        else:
            self.setLineWrapMode(QPlainTextEdit.LineWrapMode.NoWrap)
            self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)




